#!/usr/bin/python3
# -*- coding:utf-8 -*-
# __author__ == taoyulong2018@gmail.com
# __time__ == 2023/8/25 17:25
# ===========================================
#       题目名称： 41. 缺失的第一个正数
#       题目地址： https://leetcode.cn/problems/first-missing-positive/submissions/
#       题目描述： https://note.youdao.com/s/RRXNSXjR
# ===========================================


class Solution:
    """
        实现思路：
            最小无符号整数
    """

    def firstMissingPositive(self, nums):
        nums.sort()
        minUnsigned = 1
        for i in range(len(nums)):
            if nums[i] == minUnsigned:
                minUnsigned += 1
        return minUnsigned


if __name__ == '__main__':
    s = Solution()
    # 3
    print(s.firstMissingPositive(nums=[1, 2, 0]))
    # 2
    print(s.firstMissingPositive(nums=[3, 4, -1, 1]))
    # 1
    print(s.firstMissingPositive(nums=[7, 8, 9, 11, 12]))
    # 3
    print(s.firstMissingPositive(nums=[2, 1]))
